Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove one call to get_ssh_client() #710

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mykaul
Copy link

@mykaul mykaul commented Apr 24, 2018

Since in ssh_reachable() we already get a SSH client connection,
let's save it in the (unused so far) _ssh_client var.
Then reuse it, in _scp() command.

@mykaul mykaul force-pushed the one_less_ssh_only branch 2 times, most recently from 652856e to fe3baaa Compare April 25, 2018 07:06
Since in ssh_reachable() we already get a SSH client connection,
let's save it in the (unused so far) _ssh_client var.
Then reuse it, in _scp() command.
@mykaul
Copy link
Author

mykaul commented Apr 26, 2018

ci test please

@mykaul
Copy link
Author

mykaul commented May 1, 2018

ci test please

@mykaul
Copy link
Author

mykaul commented May 6, 2018

ci please test

@mykaul
Copy link
Author

mykaul commented May 8, 2018

ci test please

password=self._spec.get('ssh-password'),
)
if self._ssh_client is not None:
client = self._ssh_client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the same client in multiple threads?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it would be better to add try/catch when trying to get the client in _scp.
It will prevent a case where:

  1. You check if the vm is ssh reachable
  2. Something makes the vm go offline
  3. You call the _scp context manager.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What am I supposed to do in this case? What do I do in the catch? Nothing I can do then if the VM is offline - we'll fail miserably anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You can fall back to use libguestfs.
  2. Print an explanation about the failure. It's better than to see the entire stack trace on screen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use the client in different threads - it is actually closed after the SCP.

I thought libguestfs doesn't work - but I guess I could once you get your new exception in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants